﻿using NUnit.Framework;
using StreetPacMan.Server.Infra;

namespace StreetPacMan.Server.Tests
{
    public class BaseCleaner
    {
        [TearDown]
        public void TearDownMethod()
        {
            Cleanup();
        }

        public static void Cleanup()
        {
            using (var dbConnection = ConnectionProviderFactory.GetConnectionProvider().GetConnection())
            using (var pacManDataContext = new PacManDataContext(dbConnection))
            {
                pacManDataContext.ExecuteCommand(Filler_ForDebuggingPurposes.GetCleanupCommandString());
                //pacManDataContext.Players.DeleteAllOnSubmit(pacManDataContext.Players);
                //pacManDataContext.Apples.DeleteAllOnSubmit(pacManDataContext.Apples);
                //pacManDataContext.Events.DeleteAllOnSubmit(pacManDataContext.Events);
                //pacManDataContext.Games.DeleteAllOnSubmit(pacManDataContext.Games);
                //pacManDataContext.SubmitChanges();
            }
        }
    }

    public class BddBase
    {
        [TestFixtureTearDown]
        public void TearDownMethod()
        {
            BaseCleaner.Cleanup();
        }
    }
}